package com.atguigu.acl.service.impl;

import com.atguigu.acl.entity.ResourceCategory;
import com.atguigu.acl.mapper.ResourceCategoryMapper;
import com.atguigu.acl.service.ResourceCategoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author smday
 * @since 2020-08-10
 */
@Service
public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMapper, ResourceCategory> implements ResourceCategoryService {

    @Override
    public List<ResourceCategory> listAll() {
        QueryWrapper<ResourceCategory> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("sort");
        return baseMapper.selectList(wrapper);
    }

    @Override
    public int create(ResourceCategory resourceCategory) {
        return baseMapper.insert(resourceCategory);
    }

    @Override
    public int update(Long id, ResourceCategory resourceCategory) {
        resourceCategory.setId(id);
        return baseMapper.updateById(resourceCategory);
    }

    @Override
    public int delete(Long id) {
        return baseMapper.deleteById(id);
    }
}
